package com.serkol.ams.service.agent.impl;

import com.serkol.ams.entity.OrderDetail;
import com.serkol.ams.entity.OrderMaster;
import com.serkol.ams.entity.Users;
import com.serkol.ams.service.UsersService;
import com.serkol.ams.service.agent.XahtanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class XahtanServiceImpl implements XahtanService{
    @Autowired
    private UsersService userService;
    @Override
    public boolean danJianHuo(OrderMaster orderMaster, List<OrderDetail> dataList) {
        Long userId = orderMaster.getUserId();
        Users byUserId = userService.findByUserId(userId);
        Long parentUserId = byUserId.getParentUserId();
        List<Users> users = userService.findMyUserParentList(userId);
        Map<Integer, Users> parentUsersLevel =new HashMap<>();
        for (int i = 0; i < users.size(); i++) {
            Users users1 = users.get(i);
            parentUsersLevel.put(i, users1);
        }
        return false;
    }
    private void danjiaFenbenUsers(Map<Integer, Users> users){

    }

    private BigDecimal assignmentPriceSuan(List<OrderDetail> goodsByList,BigDecimal price) {
        BigDecimal suanTotal = new BigDecimal(0);

        for (OrderDetail next : goodsByList) {
            BigDecimal parentPrice = new BigDecimal(0);
            parentPrice = parentPrice.add(price);
            parentPrice = parentPrice.multiply(BigDecimal.valueOf(next.getQuantity()));
            suanTotal = suanTotal.add(parentPrice);
        }

        return suanTotal;
    }
}
